package com.wangshouyu.mp.pay.v3.transactions;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @author 王守钰
 * @description 交易回调
 * @date 2020/8/14 17:03
 */
public class TransactionsQueryResponse implements Serializable {

    /**
     * 公众账号ID
     * 微信支付分配的公众账号ID（企业号corpid即为此appId）
     */
    @SerializedName(value = "appid")
    @JsonProperty(value = "appid")
    @JSONField(name = "appid")
    private String appId;

    /**
     * 商户号
     * 微信支付分配的商户号
     */
    @SerializedName(value = "mchid")
    @JsonProperty(value = "mchid")
    @JSONField(name = "mchid")
    private String mchId;

    /**
     * 交易订单id
     */
    @SerializedName(value = "transaction_id")
    @JsonProperty(value = "transaction_id")
    @JSONField(name = "transaction_id")
    private String transactionId;
    /**
     * 商户订单号
     */
    @SerializedName(value = "out_trade_no")
    @JsonProperty(value = "out_trade_no")
    @JSONField(name = "out_trade_no")
    private String outTradeNo;

    /**
     * 交易类型
     * JSAPI：公众号支付
     * NATIVE：扫码支付
     * APP：APP支付
     * MICROPAY：付款码支付
     * MWEB：H5支付
     * FACEPAY：刷脸支付
     */
    @SerializedName(value = "trade_type")
    @JsonProperty(value = "trade_type")
    @JSONField(name = "trade_type")
    private String tradeType;

    /**
     * 交易状态
     * SUCCESS：支付成功
     * REFUND：转入退款
     * NOTPAY：未支付
     * CLOSED：已关闭
     * REVOKED：已撤销（付款码支付）
     * USERPAYING：用户支付中（付款码支付）
     * PAYERROR：支付失败(其他原因，如银行返回失败)
     */
    @SerializedName(value = "trade_state")
    @JsonProperty(value = "trade_state")
    @JSONField(name = "trade_state")
    private String tradeState;

    /**
     * 交易状态描述
     */
    @SerializedName(value = "trade_state_desc")
    @JsonProperty(value = "trade_state_desc")
    @JSONField(name = "trade_state_desc")
    private String tradeStateDesc;

    /**
     * 付款银行
     */
    @SerializedName(value = "bank_type")
    @JsonProperty(value = "bank_type")
    @JSONField(name = "bank_type")
    private String bankType;

    /**
     * 附加数据
     */
    @SerializedName(value = "attach")
    @JsonProperty(value = "attach")
    @JSONField(name = "attach")
    private String attach;

    /**
     * 支付完成时间
     * 支付完成时间，遵循rfc3339标准格式，
     * 格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE，
     * YYYY-MM-DD表示年月日，
     * T出现在字符串中，表示time元素的开头，
     * HH:mm:ss表示时分秒，
     * TIMEZONE表示时区（+08:00表示东八区时间，领先UTC 8小时，即北京时间）。
     * 例如：2015-05-20T13:29:35+08:00表示，北京时间2015年5月20日 13点29分35秒。
     */
    @SerializedName(value = "success_time")
    @JsonProperty(value = "success_time")
    @JSONField(name = "success_time")
    private String successTime;

    /**
     * 支付者
     */
    @SerializedName(value = "payer")
    @JsonProperty(value = "payer")
    @JSONField(name = "payer")
    private TransactionPayer payer;


    /**
     * 订单金额信息
     */
    @SerializedName(value = "amount")
    @JsonProperty(value = "amount")
    @JSONField(name = "amount")
    private TransactionsAmount amount;

    /**
     * 场景信息
     */
    @SerializedName(value = "scene_info")
    @JsonProperty(value = "scene_info")
    @JSONField(name = "scene_info")
    private TransactionsSceneInfo sceneInfo;

    /**
     * 优惠功能
     */
    @SerializedName(value = "promotion_detail")
    @JsonProperty(value = "promotion_detail")
    @JSONField(name = "promotion_detail")
    private List<TransactionsPromotionDetail> promotionDetail;

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getMchId() {
        return mchId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    public String getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getTradeType() {
        return tradeType;
    }

    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }

    public String getTradeState() {
        return tradeState;
    }

    public void setTradeState(String tradeState) {
        this.tradeState = tradeState;
    }

    public String getTradeStateDesc() {
        return tradeStateDesc;
    }

    public void setTradeStateDesc(String tradeStateDesc) {
        this.tradeStateDesc = tradeStateDesc;
    }

    public String getBankType() {
        return bankType;
    }

    public void setBankType(String bankType) {
        this.bankType = bankType;
    }

    public String getAttach() {
        return attach;
    }

    public void setAttach(String attach) {
        this.attach = attach;
    }

    public String getSuccessTime() {
        return successTime;
    }

    public void setSuccessTime(String successTime) {
        this.successTime = successTime;
    }

    public TransactionPayer getPayer() {
        return payer;
    }

    public void setPayer(TransactionPayer payer) {
        this.payer = payer;
    }

    public TransactionsAmount getAmount() {
        return amount;
    }

    public void setAmount(TransactionsAmount amount) {
        this.amount = amount;
    }

    public TransactionsSceneInfo getSceneInfo() {
        return sceneInfo;
    }

    public void setSceneInfo(TransactionsSceneInfo sceneInfo) {
        this.sceneInfo = sceneInfo;
    }

    public List<TransactionsPromotionDetail> getPromotionDetail() {
        return promotionDetail;
    }

    public void setPromotionDetail(List<TransactionsPromotionDetail> promotionDetail) {
        this.promotionDetail = promotionDetail;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TransactionsQueryResponse that = (TransactionsQueryResponse) o;
        return Objects.equals(appId, that.appId) &&
                Objects.equals(mchId, that.mchId) &&
                Objects.equals(transactionId, that.transactionId) &&
                Objects.equals(outTradeNo, that.outTradeNo) &&
                Objects.equals(tradeType, that.tradeType) &&
                Objects.equals(tradeState, that.tradeState) &&
                Objects.equals(tradeStateDesc, that.tradeStateDesc) &&
                Objects.equals(bankType, that.bankType) &&
                Objects.equals(attach, that.attach) &&
                Objects.equals(successTime, that.successTime) &&
                Objects.equals(payer, that.payer) &&
                Objects.equals(amount, that.amount) &&
                Objects.equals(sceneInfo, that.sceneInfo) &&
                Objects.equals(promotionDetail, that.promotionDetail);
    }

    @Override
    public int hashCode() {
        return Objects.hash(appId, mchId, transactionId, outTradeNo, tradeType, tradeState, tradeStateDesc, bankType, attach, successTime, payer, amount, sceneInfo, promotionDetail);
    }

    @Override
    public String toString() {
        return "TransactionsQueryResponse{" +
                "appId='" + appId + '\'' +
                ", mchId='" + mchId + '\'' +
                ", transactionId='" + transactionId + '\'' +
                ", outTradeNo='" + outTradeNo + '\'' +
                ", tradeType='" + tradeType + '\'' +
                ", tradeState='" + tradeState + '\'' +
                ", tradeStateDesc='" + tradeStateDesc + '\'' +
                ", bankType='" + bankType + '\'' +
                ", attach='" + attach + '\'' +
                ", successTime='" + successTime + '\'' +
                ", payer=" + payer +
                ", amount=" + amount +
                ", sceneInfo=" + sceneInfo +
                ", promotionDetail=" + promotionDetail +
                '}';
    }
}
